home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Fonts / metafont / cm folder / Technical Problem < prev   
Encoding:
Text File  |  1995-02-17  |  3.7 KB  |  83 lines  |  [TEXT/TBB6]

  1. (To read this, please use monospace font like 'Courier.'
  2.  
  3. Converted by TTConverter 1.5, the Mac version METAFONT TrueType fonts have
  4. some problems:
  5.         * character #1--#32 and #127 are printable characters.
  6.            Mac cannot handle this.
  7.  
  8. Therefore, I modify (re-map) 'cmap' table of the font.  Because char 0 to
  9. char 31 (decimal) characters are repeated at char 128, I assigned them (0-31) to glyph 0 (missing character; space).  char 32 of the font is not a space and char
  10. 127 of the font has a printable character, so I remap them at char 160 and char
  11. 255 and assign char 32 and char 127 with glyph 0.
  12.  
  13. After this, the converted font seems to work fine on screen and QuickDraw 
  14. printer (StyleWriter II), but not on PostScript Pinters (LaserWriter.)  The
  15. sympton is the printed characters overlap one another at each line.  It sounds
  16. like the space width which the system thought is different from the actual one. 
  17.    
  18. I finally solved the mysterious 'advance width' unmatching problem.
  19.  
  20. The problem is that Mac's PostScript printer driver (LaserWriter) treats glyf 3
  21. differently.  On the Microsoft's TrueType font specifications Appendix C,
  22. there's "Apple's Mapping Requirements and Recommendations".  It suggests the
  23. first four glyfs be better
  24.  
  25.         Glyf #                Name
  26.         ---------------------------------------------
  27.         0                     Missing Character glyf
  28.         1                     Null
  29.         2                     CR
  30.         3                     Space
  31.         :                     :
  32.         :                     :
  33.  
  34. To get a better cross-platform compatibility, this rule has to be observed.
  35. Unfortunately, the original (Window version) TrueType Metafonts do not follow
  36. it.
  37.  
  38. Previously, I only used 'cmap' re-mapping technique to assign char0 -- char 32
  39. to glyf 0.  This works most of the time, except generating PostScript codes.
  40. For some unknown reasons, the printer driver won't use 'cmap' table to retrieve
  41. char 32's 'advance width' information (in 'hmtx' table), while calculating the
  42. spacing in a line.  In a result, no matter what char 32 is mapped to in 'cmap'
  43. table, the printer driver always takes entry 03 (the 4th) in 'hmtx' as the 
  44. 'advance width' of SPACE.  In this TrueType Metafont case, the printer driver
  45. takes the width of 'Capital Theta' as that of SPACE (wider than it should be).
  46. The calculated spacing is that characters overlap one another (because an extra
  47. space will be inserted between characters, and the spaces will be scaled down
  48. to justify the words in a line--the scale-down effect is much larger than it
  49. should be.)
  50.  
  51. So, my solution is:
  52.         make entry 03 of 'hmtx' identical to entry 0
  53.         'cmap' entry for char 32 is 03 (however, 'loca' #3 will map
  54.         it to the real glyf--glyf 0)
  55.  
  56. Here's the details:
  57.  
  58. cmap        loca        glyf        hmtx
  59. #0 ------>   #0-+=====> #0          xx (width of SPACE)
  60. :            :  | +---->#1          :
  61. :            :  | | +-->#2          :
  62. #32------>   #3-+ | | +->#3         xx (width of SPACE)
  63. :            :    | | |  :          :
  64. :            :    | | |  :          :            
  65. #128------>  #128-+ | |  :          :  (width of Capital Gamma)
  66. #129------>  #129---+ |  :          :  (width of Capital Delta)
  67. #130------>  #130-----+  :          :  (width of Capital Theta)
  68. :            :           :          :
  69.  
  70. The reason of remapping 'loca' table #128 -- #130 is that they are 'composite
  71. glyf' and they internally (in glyf #128--#130 glyf instructions) map themselves
  72. back to 'loca' #1 -- #3 and loca #3 no longer maps to glyf #3.  (To follow
  73. the rule of glyf #0 -- glyf #3, actually 'loca' #0 -- #3)
  74.  
  75.  
  76. Finally, I got this conversion work.
  77.  
  78. Regards.
  79.  
  80. Chen, Nien-Po                npchen@physics.purdue.edu
  81. Feb 17 1995
  82.  
  83.